       {  Petrova Tatjana
          2012 / 09 / 25
          This program writes you the destination. }
program Destination;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  a,b,c,a1,b1,c1,x1,y1,x2,y2,x3,y3,x4,y4:integer;
  xp,yp,d:real;

begin
  readln(x2,y2);
  readln(x1,y1);
  readln(x4,y4);
  readln(x3,y3);
  a:= y1-y2;
  b:=x2-x1;
  c:=x1*y2-x2*y1;
  a1:= y3-y4;
  b1:=x4-x3;
  c1:=x3*y4-x4*y3;
  if ( (b1*a-a1*b)<>0) then
  begin
    xp:=(a1*c-c1*a)/(b1*a-a1*b);
    yp:=(-b*xp-c)/a ;
    if ((x2-x1)*(xp-x1)>=0) and((y2-y1)*(yp-y1)>=0)and((x4-x3)*(xp-x3)>=0) and((y4-y3)*(yp-y3)>=0)then
    begin
      writeln('0');
      readln;
    end else begin
     d:=sqrt((x2-x4)*(x2-x4)+(y2-y4)*(y2-y4));
     writeln(d);
     readln;
    end
  end else
  begin
     d:=sqrt((x2-x4)*(x2-x4)+(y2-y4)*(y2-y4));
     writeln(d);
     readln;
  end;
  readln;


end.

